function [ encodedSignal ] = encode( data )
%ENCODE Summary of this function goes here
%   Detailed explanation goes here

    [y, Fs, nbits, readinfo] = wavread(data);
    %[y, Fs, nbits, readinfo] = wavread('soundfile-wav/left_0.wav');

    fs = Fs / 100;

    frameOverlap = round(1/4);
    %y = y ./ max(abs(y));
    
    %Split the signal into frames
    frames = buffer(y, fs, frameOverlap);
    
    %create hamming matrix
    s = size(frames);
    ham = hamming(s(1));
    
    for i = 1:s(2)
        frames(:,i) = frames(:,i) .* ham;
    end
    
    %means = mean(frames);
    
    NFFT = 2^nextpow2(fs);
    Y = fft(means, NFFT);
    %Y = fft(means, NFFT) / L;
    
    %Hva er poenget med denne utregningen? 
    %Hvordan finne flere peaks?
    amplitudes = 2*abs(Y(1:NFFT/2+1));
   
    %[pks locs] = findpeaks(amplitudes, 'sortstr', 'descend');
    [MAXTAB MINTAB] = PEAKDET(amplitudes, 0.000000000000000000001);
    MAXTAB
    %size(pks)
    %encodedSignal(:,1) = pks(1:2);
    %encodedSignal(:,2) = locs(1:2);
    
    %plot(amplitudes);
    encodedSignal = amplitudes;
end

